{template 'web/common/common'}
{template 'web/order/navbar'}
<!-- <link rel="stylesheet" type="text/css" href="../addons/kundian_farm/resource/css/style.css" />
<link rel="stylesheet" type="text/css" href="../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.css" />
<div class="panel panel-success">
    <div class="panel-heading">
        <h3 class="panel-title">
            种植摘取配送订单>编辑
        </h3>
    </div>
    <div class="panel-body">
        <form id="sign-form" class="form-horizontal" role="form" method="post" action="{url 'site/entry/order',array('m'=>'kundian_farm','op'=>'saveModel','version_id'=>$_GPC['version_id'])}" name="submit" style="padding: 20px 0;">
            <input type="hidden" name="id" value="{$orderData['id']}">
            <table class="table-striped table-bordered table-hover dataTables-example table">
                <thead>
                    <caption>收货信息</caption>
                    <tr>
                        <td>订单编号</td>
                        <td>订单总价</td>
                        <td>收货人</td>
                        <td>联系电话</td>
                        <td>收货地址</td>
                        <td>快递单号</td>
                    </tr>
                    <tr>
                        <td>{$orderData['order_number']}</td>

                        <?php if($orderData['status']==0){?>
                        <td><input type="text" name="total_price" value="{$orderData['total_price']}">
                            <input type="hidden" name="order_id" value="{$orderData['id']}"></td>
                        <?php }else{?>
                        <td>{$orderData['total_price']}</td>
                        <?php } ?>
                        <td>{$orderData['name']}</td>
                        <td>{$orderData['phone']}</td>
                        <td>{$orderData['address']}</td>
                        <td>{$orderData['send_number']}</td>
                    </tr>
                <tr>
                    <td>订单状态</td>
                    <td>下单时间</td>
                    <td>支付时间</td>
                    <td>支付方式</td>
                    <td>备注</td>
                </tr>
                    <tr>
                        <td>{if $orderData['status']==0}
                            未支付
                            {else if $orderData['status']==1}
                            待配送
                            {else if $orderData['status']==2}
                            待确认
                            {else if $orderData['status']==3}
                            已完成
                            {else if $orderData['status']==4}
                            申请取消
                            {else}
                            已取消
                            {/if}</td>
                        <td><?php echo date("Y-m-d H:i:s",$orderData['create_time']);?></td>
                        <td><?php echo date("Y-m-d H:i:s",$orderData['pay_time']);?></td>
                        <td><?php echo $orderData['pay_method'];?></td>
                        <td><?php echo $orderData['remark'];?></td>
                    </tr>
                </thead>

            </table>

            <table class="table-striped table-bordered table-hover dataTables-example table">
                <thead>
                <caption>商品信息</caption>
                <tr>
                    <td>id</td>
                    <td>商品名称</td>
                    <td>封面</td>
                    <td>价格</td>
                    <td>规格</td>
                    <td>购买数量</td>
                </tr>
                <?php foreach($order_detail as $v){?>
                <tr>
                    <td><?php echo $v['id'];?></td>
                    <td><?php echo $orderData['body'];?></td>
                    <td><img src="<?php echo $v['cover'];?>" style="width: 70px;height: 70px;" alt=""></td>
                    <td><?php echo $v['price'];?></td>
                    <td>
                        无
                    </td>
                    <td><?php echo $v['count'];?></td>
                </tr>
                <?php } ?>
                </thead>
            </table>
            <?php if($orderData['status']==0 || $orderData['status']==5){?>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <input type="hidden" name="order_id" value="<?php echo $orderData['id']?>">
                    <button class="btn" id="deleteOrder" type="button">删除订单</button>
                </div>
            </div>
            <?php }?>

            <?php if($orderData['status']==1){?>
            <div class="form-group">
                <label class="col-sm-2 control-label">快递公司</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control"  name="express_company" value="{$orderData['express_company']}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">物流编号</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control"  name="send_number" value="{$orderData['send_number']}">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <input type="hidden" name="order_id" value="<?php echo $orderData['id']?>">
                    <button class="btn" id="sendGoods" type="button">开始配送</button>
                </div>
            </div>
            <?php }?>

            <?php if($orderData['status']==2){?>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <input type="hidden" name="order_id" value="<?php echo $orderData['id']?>">
                    <button class="btn" id="confirmGoods" type="button">完成配送</button>
                </div>
            </div>
            <?php }?>
        </form>
    </div>
</div> -->
<link rel="stylesheet" type="text/css" href="../addons/kundian_farm/resource/css/style.css" />
<link rel="stylesheet" type="text/css" href="../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.css" />
<link rel="stylesheet" type="text/css" href="../addons/kundian_farm/resource/css/layui.css" />
<link rel="stylesheet" type="text/css" href="../addons/kundian_farm/resource/css/new-common.css" />
<div style="padding: 20px; background-color: #F2F2F2;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">种植配送订单</div>
                <div class="layui-card-body">
                    <form id="myform" action="{url 'site/entry/order',array('m'=>'kundian_farm','op'=>'seed_order','status'=>$_GPC['status'],'version_id'=>$_GPC['version_id'])}" method="post">
                        <div class="layui-form-item">
                            <input type="text" style="width: 200px;float: left;margin-right: 20px;height: 34px;" name="order_number" lay-verify="title" autocomplete="off" placeholder="订单编号" class="layui-input">
                            {php echo tpl_form_field_daterange('time', $old_time, $time = false);}
                            <input type="hidden" name="flag" value="">
                            <input type="hidden" name="order_type" value="1">
                            <button type="submit" id="submitForm" class="layui-btn" style="height: 34px;line-height: 34px;">搜索</button>
                            <a class="layui-btn" id="outOrder" href="#">批量导出</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
    <ul class="layui-tab-title">
        <a href="{url 'site/entry/order',array('m'=>'kundian_farm','op'=>'seed_order','status'=>6,'version_id'=>$_GPC['version_id'])}" ><li class="{if $status==6}layui-this{/if}">全部</li></a>
        <a href="{url 'site/entry/order',array('m'=>'kundian_farm','op'=>'seed_order','status'=>7,'version_id'=>$_GPC['version_id'])}"><li class="{if $status==7}layui-this{/if}">未支付</li></a>
        <a href="{url 'site/entry/order',array('m'=>'kundian_farm','op'=>'seed_order','status'=>1,'version_id'=>$_GPC['version_id'])}"><li class="{if $status==1}layui-this{/if}">已支付</li></a>
        <a href="{url 'site/entry/order',array('m'=>'kundian_farm','op'=>'seed_order','status'=>2,'version_id'=>$_GPC['version_id'])}"><li class="{if $status==2}layui-this{/if}">已发货</li></a>
        <a href="{url 'site/entry/order',array('m'=>'kundian_farm','op'=>'seed_order','status'=>3,'version_id'=>$_GPC['version_id'])}"><li class="{if $status==3}layui-this{/if}">已完成</li></a>
        <a href="{url 'site/entry/order',array('m'=>'kundian_farm','op'=>'seed_order','status'=>4,'version_id'=>$_GPC['version_id'])}"><li class="{if $status==4}layui-this{/if}">申请取消</li></a>
        <a href="{url 'site/entry/order',array('m'=>'kundian_farm','op'=>'seed_order','status'=>5,'version_id'=>$_GPC['version_id'])}"><li class="{if $status==5}layui-this{/if}">已取消</li></a>
        <a href="{url 'site/entry/order',array('m'=>'kundian_farm','op'=>'seed_order','is_recycel'=>1,'version_id'=>$_GPC['version_id'])}"><li class="{if $is_recycel==1}layui-this{/if}">回收站</li></a>
    </ul>
</div>
<div class="layui-form">
    <table class="layui-table">
        <colgroup>
            <col width="50">
            <col width="100">
            <col width="200">
            <col>
        </colgroup>
        <thead>
        <tr>
            <th>ID</th>
            <th>订单编号</th>
            <th>订单总价</th>
            <th>优惠金额</th>
            <th>实际支付金额</th>
            <th>下单时间</th>
            <th>支付时间</th>
            <th>订单状态</th>
            <th>商户订单号</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {loop $list $key $item}
            <tr>
                    <td><span>{$item['id']}</span></td>
                    <td><span>{$item['order_number']}</span></td>
                    <td><span>￥{$item['total_price']}（含运费：￥{$item['send_price']}）</span></td>
                    <td><span>￥{$item['coupon_price']}</span></td>
                    <td><span>￥{$item['pra_price']}</span></td>
                    <td><span><?php echo date("Y-m-d H:i:s",$item['create_time']);?></span></td>
                    <td><span>
                        {if $item['pay_time']==0}
                        --：--
                        {else}
                        <?php echo date("Y-m-d H:i:s",$item['create_time']);?>
                        {/if}
                    </span></td>
                    <td><span>
                        {if $item['status']==0}
                        <span class="layui-badge layui-bg-gray">未支付</span>
                        {else if $item['status']==1}
                        <span class="layui-badge layui-bg-green">已支付</span>
                        {else if $item['status']==2}
                        <span class="layui-badge layui-bg-green">待收货</span>
                        {else if $item['status']==3}
                        <span class="layui-badge layui-bg-green">已完成</span>
                        {else if $item['status']==5}
                        <span class="layui-badge layui-bg-gray">已取消</span>
                        {else if $item['status']==4}
                        <a href="{url 'site/entry/refund',array('m'=>'kundian_farm','id'=>$item['id'],'version_id'=>$_GPC['version_id'])}">
                            <button type="button" class="cancel-order layui-btn layui-btn-danger">确认取消订单</button></a>
                        {/if}
                    </span>
                    </td>
                <td>{$item['uniontid']}</td>
                <td>
                    <a href="{url 'site/entry/order',array('m'=>'kundian_farm','op'=>'shop_order_edit','id'=>$item['id'],'version_id'=>$_GPC['version_id'])}">
                        <button class="layui-btn layui-btn-xs">详情</button>
                    </a>
                    {if $item['is_recycel']==1}
                    <button class="layui-btn layui-btn-xs move_into_recycel" data-id="{$item['id']}" data-type="2">移出回收站</button>
                    {else}
                    <button class="layui-btn layui-btn-xs move_into_recycel" data-id="{$item['id']}" data-type="1">移入回收站</button>
                    {/if}
                </td>

            </tr>
        {/loop}
        </tbody>
    </table>
    <span>订单总金额：</span><span style="color: red;font-size: 20px;">￥{$totalMoney}</span>
    <div style="text-align: right;">
        {$pager}
    </div>
</div>



<script>
    require(["../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.js"],function(){
        $(function(){
            $("#sendGoods").click(function () {
                var orderid=$("input[name='order_id']").val();
                var send_number=$("input[name='send_number']").val();
                var express_company=$("input[name='express_company']").val();
                if(send_number==''){
                    alert("请填写配送单号！");
                    return false;    
                }else{
                    $.ajax({
                        type:"post",
                        url:"{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'send_goods','version_id'=>$_GPC['version_id'])}",
                        data:{order_id:orderid,send_number:send_number,express_company:express_company},
                        dataType:'json',
                        success:function(res){
                            if(res.status==1){
                                swal('操作成功!', '操作成功!', 'success');
                            }else{
                                swal('操作失败!', '操作失败!', 'error');
                            }
                        }
                    })
                }
            })
            $("#confirmGoods").click(function () {
                var orderid=$("input[name='order_id']").val();
                $.ajax({
                    type:"post",
                    url:"{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'confirmGoods','version_id'=>$_GPC['version_id'])}",
                    data:{order_id:orderid},
                    dataType:'json',
                    success:function(res){
                        if(res.status==1){
                            swal('操作成功!', '操作成功!', 'success');
                        }else{
                            swal('操作失败!', '操作失败!', 'error');
                        }
                    }
                })
            })
            $("#deleteOrder").click(function () {
                var orderid=$("input[name='order_id']").val();
                $.ajax({
                    type:"post",
                    url:"{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'deleteOrder','version_id'=>$_GPC['version_id'])}",
                    data:{order_id:orderid},
                    dataType:'json',
                    success:function(res){
                        if(res.status==1){
                            swal('操作成功!', '操作成功!', 'success');
                        }else if(res.status==3){
                            swal('提示', '订单未完成!', 'error');
                        }else{
                            swal('操作失败!', '操作失败!', 'error');
                        }
                    }
                })
            })

            $("input[name='total_price']").blur(function () {
                var total_price=$(this).val();
                var orderid=$("input[name='order_id']").val();
                $.ajax({
                    type:"post",
                    url:"{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'change_price','version_id'=>$_GPC['version_id'])}",
                    data:{order_id:orderid,total_price:total_price},
                    dataType:'json',
                    success:function(res){
                        if(res.status==1){
                            swal('操作成功!', '操作成功!', 'success');
                        }else{
                            swal('操作失败!', '操作失败!', 'error');
                        }
                    }
                })
            })
        })
    })
</script>

